package temp;

import cn.yunhe.biz.Refrigerator;
import cn.yunhe.exception.OutOfStockException;
import cn.yunhe.model.Customer;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class RefrigeratorTest1 {
    ApplicationContext applicationContext=null;

    @Before
    public void initial(){
        applicationContext=new ClassPathXmlApplicationContext("spring111..xml");
    }

    @Test
    public void Test1() throws OutOfStockException {
        Refrigerator refrigerator= (Refrigerator) applicationContext.getBean("refrigerator111");
        Customer customer1=new Customer(111,"111","王大","111111");
        Customer customer2=new Customer(222,"222","李二","222222");
        Customer customer3=new Customer(333,"333","张三","333333");
        Customer customer4=new Customer(333,"333","张三1","333333");
        Customer customer5=new Customer(333,"333","张三1","333333");
        System.out.println("============111=============");
        refrigerator.saleRefrigerator(customer1,0);
        System.out.println(customer1);
        refrigerator.saleRefrigerator(customer2,0);
        System.out.println(customer2);
        refrigerator.saleRefrigerator(customer3,0);
        System.out.println(customer3);
        refrigerator.saleRefrigerator(customer4,0);
        System.out.println(customer4);
        refrigerator.saleRefrigerator(customer5,0);
        System.out.println(customer5);
        System.out.println("=============222=============");
        refrigerator.saleRefrigerator(customer1,1);
        refrigerator.saleRefrigerator(customer2,1);
        refrigerator.saleRefrigerator(customer4,1);
        System.out.println("=============333=============");
        refrigerator.saleRefrigerator(customer1,1);
        refrigerator.saleRefrigerator(customer2,1);
        refrigerator.saleRefrigerator(customer3,1);
        System.out.println("=============444=============");
        refrigerator.saleRefrigerator(customer1,1);
        System.out.println("==============555===============");

    }


}
